﻿namespace Digitalmes.Application.Mes;

[ApiExplorerSettings(GroupName = "mes")]
public sealed class ProdTransSnRecordService : IDynamicWebApiService
{
    private readonly SugarRepository<ProdTransSnRecord> _thisRepository;

    public ProdTransSnRecordService(SugarRepository<ProdTransSnRecord> thisRepository)
    {
        _thisRepository = thisRepository;
    }

    /// <summary>
    /// 查询所有——分页
    /// </summary>
    /// <param name="param"></param>
    /// <returns></returns>
    [HttpGet]
    public async Task<PageResult<ProdTransSnRecordDto>> GetPagesAsync(ProdTransSnRecordPageParam param)
    {
        var query = await _thisRepository.AsQueryable()
            .Where(s => s.Sn == param.Sn)
            .ToPageAsync(param.Page, param.Limit);
        return query.Adapt<PageResult<ProdTransSnRecordDto>>();
    }

    /// <summary>
    /// 列表
    /// </summary>
    /// <param name="param"></param>
    /// <returns></returns>
    [HttpGet]
    public async Task<List<ProdTransSnRecordDto>> GetListAsync(ProdTransSnRecordParam param)
    {
        var query = await _thisRepository
            .GetListAsync(s => s.Sn == param.Sn);
        return query.Adapt<List<ProdTransSnRecordDto>>();
    }
}
